package net;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

// InetAddress类
public class Test1 {
    @Test
    public void test1() throws UnknownHostException {
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);

    }

    @Test
    public void test2() throws UnknownHostException {
        InetAddress address = InetAddress.getByName("www.baidu.com");
        System.out.println(address);
    }

    @Test
    public void test3() throws UnknownHostException {
        byte[] address = {(byte) 192, (byte) 168, (byte) 78, (byte) 1};
        InetAddress addr = InetAddress.getByAddress(address);
        System.out.println(addr);
    }


}
